package com.sinoglobal.ningxia.activity.amusement;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.sinoglobal.ningxia.R;
import com.sinoglobal.ningxia.activity.IBase;

/**
 * @Title: AmusementDialog.java
 * @Package com.sinoglobal.ningxia.activity.amusement
 * @Description: TODO(用一句话描述该文件做什么)
 * @author czz
 * @date 2014-6-20 下午3:31:15
 */
public class AmusementDialog extends Dialog implements IBase, android.view.View.OnClickListener {

	private String message = ""; //dialog 显示信息
	private boolean cancelable = true;//设置为false，按返回键不能退出。默认为true。
	public ImageView alertIvExpression; //dialog状态图片
	public TextView alertTvMessage; //显示message
	private TextView alertBtnCancel;//取消
	private TextView alertBtnConfirm;//确定
	private AmusementDialogClickListener atdialogclick; //回调方法

	public AmusementDialogClickListener getAtdialogclick() {
		return atdialogclick;
	}
	public void setAtdialogclick(AmusementDialogClickListener atdialogclick) {
		this.atdialogclick = atdialogclick;
	}
	public AmusementDialog(Context context, String message, boolean cancelable) {
		super(context, R.style.dialog);
		this.message = message;
		this.cancelable = cancelable;
		setContentView(R.layout.dialog_amusement_view);
		init();
	}
	@Override
	public void init() {
		setCancelable(cancelable);
		alertIvExpression = (ImageView) findViewById(R.id.alert_iv_expression);
		alertTvMessage = (TextView) findViewById(R.id.alert_tv_message);
		alertBtnCancel = (TextView) findViewById(R.id.alert_btn_cancel);
		alertBtnConfirm = (TextView) findViewById(R.id.alert_btn_confirm);
		alertTvMessage.setText(message);
		alertBtnCancel.setOnClickListener(this);
		alertBtnConfirm.setOnClickListener(this);
	}
	@Override
	public void showListener() {
	}
	public static interface AmusementDialogClickListener {
		void doCancel();
		void doConfirm();
	}

	@Override
	public void onClick(View arg0) {
		switch (arg0.getId()) {
		case R.id.alert_btn_cancel:
			atdialogclick.doCancel();
			break;
		case R.id.alert_btn_confirm:
			atdialogclick.doConfirm(); 
			break;
		default:
			break;
		}
	}
	public void setText(String confirm,String cansel){
		alertBtnCancel.setText(cansel);
		alertBtnConfirm.setText(confirm);
	}
}
